package com.authstr.auth.service.inter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.authstr.auth.constant.CacheKey;
import com.authstr.auth.constant.CacheName;
import com.authstr.basic.reqres.request.RequestPara;
import com.authstr.model.base.BaseUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

public interface UserService extends IService<BaseUser> {

    Page query(@Param("page") Page page,
               @Param("role_id") String role_id,
               @Param("gmt_create_start") String gmt_create_start,
               @Param("gmt_create_end") String gmt_create_end,
               @Param("account") String account);

    @Transactional(rollbackFor=Exception.class)
    Long addOrEdit(BaseUser model, RequestPara para);

    void register(BaseUser model, RequestPara para);

    Boolean saveRoleInfo(Long userId, Long[] roleIds);

    @Transactional(rollbackFor=Exception.class)
    void delete(Long[] ids);

    @Cacheable(value = CacheName.SHIRO_CACHE ,key = "'" + CacheKey.USER_AUTH_ + "'+#account")
    BaseUser getByAccount(String account);
}
